<template>
  <el-carousel trigger="click" class="adverisementsContent">
    <el-carousel-item v-for="(item,index) in advertisements" :key="index" >
      <el-image class="adverisementsClass" style="height:100%;width:100%"  :fit="'cover'" :src="item.photo" @click="handleClick(item)"></el-image>
    </el-carousel-item>
  </el-carousel>
</template>
<script>
  import { getStoreId, getImageUrl } from '@/utils/index'
  import { dataList } from  '@/api/after-sale/systemManage/advert'
  const config = require('../../../../config')
  export default {
    data() {
      return {
        params: {
          site: '首页广告',
          type: 'PC端',
          storeId: getStoreId()
        },
        advertisements: [
          {url: ''}
        ],
      }
    },
    async created() {
      const {data, success } = await dataList(this.params, 1000, 1);
      if (success){
        this.advertisements = data.content && data.content.map(e => {
          e.photo = getImageUrl(e.photos);
          return e
        });
      }
    },
    methods: {
      handleClick(item){
        window.open(item.url, '_blank');
      }
    }
  }
</script>
<style  lang="scss" scoped>
.adverisementsContent{
  height: 290px;
  overflow: hidden;
  /deep/ .el-carousel__item{
    height: 285px;
  }
}
</style>